# cmake_minimum_required(VERSION 3.10)
# project(DoseStatistics)

#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx dose_statistics lib
set(MY_LIB dosestatcuda)
add_library(${MY_LIB} SHARED)
#--- 使用自定义函数配置导出头文件
my_config_export_header(${MY_LIB} ${MY_EXPORTS_DIR})

target_sources(${MY_LIB}
    PRIVATE
        DoseStatCuda.cu
        CudaFloats.cu
    PUBLIC
        CudaFloats.cuh
        DoseStatCuda.h
)
# 添加头文件搜索路径
target_include_directories(${MY_LIB}
    PUBLIC
        "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
        "$<INSTALL_INTERFACE:include>"
)
# 链接依赖库
target_link_libraries(${MY_LIB}
    PUBLIC common
    ## PRIVATE ${CUDA_cudart_LIBRARY}
    PRIVATE CUDA::cudart
)

install(TARGETS ${MY_LIB}
    RUNTIME DESTINATION bin
    LIBRARY DESTINATION bin
    ARCHIVE DESTINATION bin
)

#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 添加测试用例
set(MY_LIB_TE testdosestatcuda)
include(00testdosestatcuda.cmake)

#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 添加Python绑定模块
set(MY_PY_BIND "dosestatcudapy")
include(01pybind11cuda.cmake)

##============================= 为Visual Studio生成文件夹结构（如果适用）
if(MSVC)
    set_property(GLOBAL PROPERTY USE_FOLDERS ON)
    set_target_properties(${MY_LIB} PROPERTIES FOLDER "dosestatcuda")
    set_target_properties(${MY_LIB_TE} PROPERTIES FOLDER "dosestatcuda")
    set_target_properties(${MY_PY_BIND} PROPERTIES FOLDER "dosestatcuda")
endif()

##============================= 添加编译选项以提高代码质量
if(FALSE AND MSVC)
    target_compile_options(${MY_LIB} PRIVATE /W4 /WX)
endif()
if(LINUX)
    # target_compile_options(${MY_LIB} PRIVATE -Wall -Wextra -Wpedantic -Werror)
    target_compile_options(${MY_LIB} PRIVATE -Wall -Wextra)
endif()